// pages/hospitalMoreDetail/index.js
// pages/consultationList/index.js
const app = getApp()
let {
  baseUrl,
  commonUpdate,
  commonUpload
} = app.globalData
import {
  ApiGetDepartmentDoctorList
} from '../../api/index'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    baseUrl,
    commonUpdate,
    commonUpload,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      arrData: JSON.parse(options.data)
    })
    this.getDepartmentDoctor()
  },


  getDepartmentDoctor(id, date) {
    ApiGetDepartmentDoctorList({
      sub_department_id: this.data.arrData.department_id,
    }).then(res => {
      this.setData({
        dateList: res.data.dateList,
        department: res.data.department,
        doctorList: res.data.doctorList
      })
      wx.hideLoading()
    })
  },

  dealTime: function () { // num：未来天数
    const currentDate = new Date();
    const year = currentDate.getFullYear();
    const month = String(currentDate.getMonth() + 1).padStart(2, '0');
    const day = String(currentDate.getDate()).padStart(2, '0');
    const formattedDate = `${year}-${month}-${day}`;
    return formattedDate // 返回对象
  },

  
  doctorListClick(e) {
    let date = this.dealTime()
    wx.setStorageSync('order_type', '图文问诊')
    wx.navigateTo({
      url: `/pages/doctorDetails/index?id=${e.currentTarget.dataset.v.id}&&index1=-1&&date=${date}`,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})